package com.beiing.tianshuai.tianshuai.message.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CreateGroupBean;
import com.beiing.tianshuai.tianshuai.entity.MyFriendListBean;
import com.beiing.tianshuai.tianshuai.message.model.CreateGroupModel;
import com.beiing.tianshuai.tianshuai.message.model.CreateGroupModelImpl;
import com.beiing.tianshuai.tianshuai.message.view.CreateGroupViewImpl;

/**
 * Created by Jinni on 2017/9/19 0019.
 */

public class CreateGroupPresenter extends BasePresenter implements CreateGroupPresenterImpl, CreateGroupModel.OnRequestListener {

    private CreateGroupViewImpl     mView;
    private CreateGroupModelImpl    mModel;

    public CreateGroupPresenter(CreateGroupViewImpl view) {
        mView = view;
        mModel = new CreateGroupModel(this);
    }

    @Override
    public void getCreateGroupRequest(String uid, String groupName, String groupDesc, String groupNotice, String members) {
        mView.showProgress();
        mModel.getCreateGroupRequest(uid, groupName, groupDesc, groupNotice, members);
    }

    @Override
    public void getMyFriendList(String uid) {
        mView.showProgress();
        mModel.getMyFriendList(uid);
    }

    @Override
    public void onSuccess(MyFriendListBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onCreateSuccess(CreateGroupBean bean) {
        mView.createGroupSuccess(bean);
    }

    @Override
    public void onError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }
}
